package com.tony.easymvc.core;

import java.io.IOException;
import java.sql.SQLException;

import org.jdom2.JDOMException;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.exception.XMLParserException;

import com.tony.easymvc.core.bean.DbConfig;
import com.tony.easymvc.core.bean.ProjectModel;

public class TestMain {

	public static void main(String[] args) throws IOException, XMLParserException, InvalidConfigurationException,
			SQLException, InterruptedException, JDOMException {
		// build project model
		ProjectModel project = new ProjectModel();
		project.setGroupId("com.tony.test");
		project.setArtifactId("abc2");
		project.setVersion("1.0");
		project.setDriverClassName("com.mysql.jdbc.Driver");

		DbConfig master = new DbConfig();
		master.setUrl("jdbc:mysql://10.100.28.184:3306/easymvc?useInformationSchema=true");
		master.setUsername("ry");
		master.setPassword("123456");
//		project.setMaster(master);
		project.setBasePath("/Users/huahua/git/output");

		project.setPix("tony");
		project.setScanPackage("com.tony");
		project.setMapperPackage("com.tony.easymvc.dal");
		project.setPoPackage("com.tony.easymvc.po");
		project.setControllerPackage("com.tony.abc.controller");

		project.setDruidUser("admin");
		project.setDruidPassword("scm123456");

		// project.getTableNames().add("mock_service,MockService1");
		// project.getTableNames().add("protocol_config");
		// project.getTableNames().add("registry_config");
		project.setJdbcPath(
				"/Users/huahua/maven/repo/mysql/mysql-connector-java/5.1.26/mysql-connector-java-5.1.26.jar");

		// project.setJdbcPath("/Users/tonyruiyu/mavenlib/mysql/mysql-connector-java/5.1.6/mysql-connector-java-5.1.6.jar");
		ProjectGenerator generator = new ProjectGenerator();
		generator.perform(project, null);

		// resolve tmplate
		// String s = TemplateUtils.loadTempl("tmpl/p_pom.tmpl");
		// Template t = new TemplateImpl("xxx", s);
		// Map<String, Object> c = Maps.newHashMap();
		// c.put("project", project);
		// String bb = t.resolve(c);
		// System.out.println(bb);
	}

}
